package com.lagou.mr;

import org.apache.hadoop.io.NullWritable;
import org.apache.hadoop.io.Text;
import org.apache.hadoop.mapreduce.Reducer;

import java.io.IOException;

public class NumReducer extends Reducer<NumBean, NullWritable,Text,NumBean> {
    private int i = 0;
    private Text outk = new Text();

    @Override
    protected void reduce(NumBean outv, Iterable<NullWritable> values, Reducer<NumBean, NullWritable, Text, NumBean>.Context context) throws IOException, InterruptedException {
        for (NullWritable value : values) {
            outk.set((++i)+""); //实现前排对有序数据的排序序号
            context.write(outk,outv);
        }
    }
}
